package com.nba.service.impl;

import java.util.List;

import com.nba.bean.Page;
import com.nba.bean.Team;
import com.nba.bean.inherit.TeamInherit;
import com.nba.dao.TeamDao;
import com.nba.dao.impl.TeamDaoImpl;
import com.nba.service.TeamService;

public class TeamServiceImpl implements TeamService {
	
	private TeamDao teamdao = new TeamDaoImpl();

	@Override
	public List<Team> getAllTeam() {
		return teamdao.selectTeamAll();
	}

	@Override
	public int deleteTeam(int teamId) {
		// TODO Auto-generated method stub
		return teamdao.deleteTeamById(teamId);
	}

	@Override
	public int addTeam(Team team) {
		// TODO Auto-generated method stub
		return teamdao.insertTeam(team);
	}

	@Override
	public Team getTeam(int teamId) {
		// TODO Auto-generated method stub
		return teamdao.selectTeamById(teamId);
	}

	@Override
	public Page<TeamInherit> getTeam(String keyword ,int pageNum, int pageSize) {
		List<TeamInherit> teams = teamdao.selectTeam(keyword,pageNum, pageSize);
		int totalRows = teamdao.selectTeamTotalRows(keyword);
		Page<TeamInherit> page = new Page(teams,pageNum,pageSize,totalRows);
		return page;
	}

	@Override
	public int updateTeam(Team team) {
		return teamdao.updateTeam(team);
	}

	@Override
	public Team selectTeamByName(String teamName) {
		return teamdao.selectTeamByName(teamName);
	}

}
